<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title></title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="icon" href="">
    <link href="https://static.9hive.cn/global/vendor/bootstrap-3.3.7/bootstrap.min.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/nprogress/nprogress.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/fonts/font-awesome/font-awesome.min.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/icheck/icheck.min.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/animate/animate.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/bootstrap-table-1.11/bootstrap-table.min.css?v=1.1" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/common/common_20170925.css" rel="stylesheet">
    <link href="https://static.9hive.cn/global/vendor/inside/inside.css?v=1" rel="stylesheet">
    <link href="/res/plugins/loading/loading.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        // 删除
        function deleteCategory(ids) {
            parent.layer.confirm('您确定要删除吗？', {
                btn: ['是','否'] //按钮
            }, function(){
                $.ajax({
                    method:"post",
                    url: '${base}/shop/productCategroy/delete',
                    data:"id=" + ids + "",
                    dataType: "json",
                    async: false,
                    success: function(data) {
                        parent.layer.msg(data.message);
                        if (data.status == "success") {
                            location.href='/shop/productCategroy/list';
                        }
                    }
                });
            });
        }
    </script>
</head>

<body class="white-bg">
<div class="wrapper wrapper-content ibox float-e-margins">
    <div class="ibox-title">
        <div class="pull-left mbx">
            商品分类<span class="line">/</span>
            <span class="current">商品分类列表</span>
        </div>
    </div>
    <div class="ibox-content">
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="col-sm-12" >
                    <div class="alert alert-warning alert-dismissable">
                        <button aria-hidden="true" data-dismiss="alert" class="close" type="button">×</button>
                        可以对资源进行管理，并进行增删改查。
                    </div>
                    <div class="btn-group hidden-xs" id="eventsToolbar" role="group" style="margin-bottom: -55px">
                        <button type="button" class="btn btn-outline btn-default"  id="add">
                            <i class="glyphicon glyphicon-plus" aria-hidden="true"></i>添加
                        </button>
                    </div>
                    <table id="rTableEvents" data-toggle="table" data-mobile-responsive="true" data-pagination="true" data-search="true" class="table table-bordered table-strip table-hovered">
                        <thead>
                        <tr>
                            <th>分类名称</th>
                            <th>排序</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <%for(list in productCategoryTreeList){%>
                        <tr level="${list.level!}">
                            <td>
                        <span style="margin-left: ${list.level * 20}px;">
                            <%if (list.level == 0){%>
                                <i class="am-icon-folder-o"></i>
                            <%}else{%>
                                <i class="am-icon-folder-open-o"></i>
                            <%}%>
                        ${list.name}
                        </span>
                            </td>
                            <td>${list.orderList}</td>
                            <td>
                                <div>
                                    <div>
                                        <%if (list.children.~size > 0){%>
                                        <a disabled="disabled" style="color:#999;font-size:15px" class="fa fa-trash-o" data-toggle="tooltip" title="删除"></a>
                                        <%}else{%>
                                        <a id="deleteAction" onclick="deleteCategory('${list.id}')" class="fa fa-trash-o" data-toggle="tooltip" title="删除" style="font-size: 15px"></a>
                                        <%}%>
                                        <a onclick="location.href='${base}/shop/productCategroy/edit?id=${list.id}'"><span style="margin-left:10px;font-size: 15px" class="fa fa-pencil" data-toggle="tooltip" title="编辑"></span></a>
                                    </div>
                                </div>
                            </td>
                        </tr>
                        <%}%>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="https://static.9hive.cn/global/vendor/jquery/jquery-2.1.4.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/nprogress/nprogress.js"></script>
<script src="https://static.9hive.cn/global/vendor/bootstrap-3.3.7/bootstrap.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/jquery-validate/jquery.validate.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/jquery-validate/additional-methods.min.js"></script>

<script src="https://static.9hive.cn/global/vendor/jquery-validate/localization/messages_zh.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/jquery-ajaxform/ajax-form.js"></script>
<script src="https://static.9hive.cn/global/vendor/bootstrap-table-1.11/bootstrap-table.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/bootstrap-table/extensions/mobile/bootstrap-table-mobile.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/bootstrap-table-1.11/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="https://static.9hive.cn/global/vendor/layer/layer.js"></script>

<script>

    function del(v) {
        $.post('delete',{"ids":v},function (e) {
            if(e.status == 'error'){
                toastr.error(e.message, '提示')
            }else{
                toastr.success('删除成功', '提示');
                $('#cpTableEvents').bootstrapTable('refresh');
            }
        })
    }
    function edit(v) {
        location.href = "edit?id="+v;
    }

    (function() {
        $('#cpTableEvents').bootstrapTable({
            url: "${base}/shop/role/ajaxlist",
            search: true,
            pagination: true,
            showRefresh: true,
            showToggle: true,
            showColumns: true,
            iconSize: 'outline',
            toolbar: '#eventsToolbar',
            icons: {
                refresh: 'glyphicon-repeat',
                toggle: 'glyphicon-list-alt',
                columns: 'glyphicon-list'
            }
        });
        $(".wrapper").tooltip({selector:"[data-toggle=tooltip]",container:"body"});

        $('#eventsToolbar').on('click',function (e) {
            location.href = 'add';
        })

        toastr.options = {
            "positionClass" : "toast-top-center"
        };

        if('${type!}' == 'save')
            toastr.success('添加成功', '提示')
        if('${type!}' == 'del')
            toastr.success('删除成功', '提示')
    })();
</script>
</body>

</html>
